import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex);
export default new Vuex.Store({
  state: {
     tokenstatic:'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vaXRlbS5mYW56aGFuZ2d1aS50ZXN0LnNzenNob3cuY29tL3VzZXJfYmFzZS91c2VyL2dldF9vcGVuaWQiLCJpYXQiOjE1MTIzNzc3MTIsImV4cCI6MTUxMjM4MTMxMiwibmJmIjoxNTEyMzc3NzEyLCJqdGkiOiJjZmJiZTM4ZThlOWMzNzUxMTU5YjQ3NTYzZTE4OTgyOSIsInN1YiI6Nn0.ElmLRVv7VDlE_JvXLFUGNFILxiejeIkhr3Gw6m55yz8',
    //  token:null,
     base:'/apis',
     url:'https://item.fanzhanggui.test.sszshow.com',
     urlchild:{
       cart:'/shop/user/cart/show',
       num:'/shop/user/cart/update',
       clear:'/shop/user/cart/clear',
       del:'/shop/user/cart/del',
       tokenhongqi:null,
     }
  },
  mutations: {
    updateToken(state, obj) {
     state.token=obj;
     console.log(state.token)
     }
  },
  actions: {
    // token的获取
      getToken({ commit }) {
        axios({
            url: base + '/user_base/user/get_code',
            // http://item.fanzhanggui.test.sszshow.com/user_base/user/get_code
            method: 'get'
          })
          .then((res) => {
              commit('updateToken',res.data.token);
          })
      },
      
  }
})
